//
//  TORadioTableCell.m
//  B段项目
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "TORadioTableCell.h"

@implementation TORadioTableCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubView];
    }
    return self;
}


-(void)createSubView{
    
    //电台类型图片
    self.radioImageView = [[UIImageView alloc] init];
        self.radioImageView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.radioImageView];
    
    [self.radioImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.contentView).offset(20);
        make.centerY.equalTo(self.contentView);
        make.height.width.mas_equalTo(HEIGHT/8);
    }];
    
    //取中间部分放入框中
    self.radioImageView.contentMode = UIViewContentModeScaleAspectFill;
    //剪裁边缘
    self.radioImageView.clipsToBounds = YES;
    
    
    //电台标题
    self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.backgroundColor = [UIColor clearColor];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:18];
    self.titleLabel.textColor = [UIColor colorWithRed:0.52 green:0.52 blue:0.52 alpha:1];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.radioImageView.mas_right).offset(10);
        make.right.mas_equalTo(-20);
        make.top.mas_equalTo(self.radioImageView);
        make.height.mas_equalTo(self.radioImageView.mas_height).multipliedBy(0.35);
    }];
    
    
    //主播
    self.hostLabel = [[UILabel alloc] init];
    self.hostLabel.font = [UIFont systemFontOfSize:13];
    self.hostLabel.textColor = [UIColor colorWithRed:0.43 green:0.52 blue:0.63 alpha:1];
        self.hostLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.hostLabel];
    
    [self.hostLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLabel.mas_bottom);
        make.right.left.height.mas_equalTo(self.titleLabel);
      
    }];
    
    
    //描述
    self.describeLabel = [[UILabel alloc] init];
    self.describeLabel.font = [UIFont systemFontOfSize:13];
    self.describeLabel.backgroundColor = [UIColor clearColor];
    self.describeLabel.textColor = [UIColor colorWithRed:0.77 green:0.77 blue:0.77 alpha:1];
    [self.contentView addSubview:self.describeLabel];
    [self.describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.hostLabel.mas_bottom);
        make.right.left.height.mas_equalTo(self.titleLabel);
    }];
}

-(void)setRadioMl:(TORadioModel *)radioMl
{
    _radioMl = radioMl;
    
    [self.radioImageView sd_setImageWithURL:self.radioMl.coverimg placeholderImage:PLACEHOLDER_IMAGE];
    self.titleLabel.text = self.radioMl.title;
    self.describeLabel.text = self.radioMl.desc;
//    NSString *str = [NSString stringWithFormat:@"by:%@",[self.radioMl.userinfo objectForKey:@"uname"]];
    self.hostLabel.text = [NSString stringWithFormat:@"by:%@", self.radioMl.uname];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
